﻿using DataManage;
using ServiceLayerManagement;
using System.Windows;

namespace BMSPlatform
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            GlobalData.AppStart();
        }

        private void Application_Exit(object sender, ExitEventArgs e)
        {
            GlobalData.AppStop();
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            this.DispatcherUnhandledException += App_DispatcherUnhandledException;
        }

        private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            // 在这里处理未处理的异常
            MessageHelper.Info($"发生未处理的异常: {e.Exception.Message}");

            // 标记为已处理
            e.Handled = true;
        }
    }
}
